package com.yang.qgg_demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yang.qgg_demo.entity.ShoppingCart;
import com.yang.qgg_demo.mapper.ShoppingCartMapper;
import com.yang.qgg_demo.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {
    @Autowired
    private ShoppingCartMapper shoppingCartMapper;

    public List<ShoppingCart> getAllCartsWithMoneyGreaterThanZero() {
        QueryWrapper<ShoppingCart> queryWrapper = new QueryWrapper<>();
        queryWrapper.gt("money", 0); // 查询money字段大于0的记录
        return list(queryWrapper); // 使用MyBatis-Plus提供的list方法执行查询
    }
    public void clearAllData() {
        QueryWrapper<ShoppingCart> queryWrapper = new QueryWrapper<>();
        shoppingCartMapper.delete(queryWrapper); // 删除所有数据
    }
}
